:root {
  // line number
  --code-line-number-width: 3rem;
}

div[class*='language-'] {
  &:not(.line-numbers-mode) {
    .line-numbers {
      display: none;
    }
  }

  &.line-numbers-mode {
    &::after {
      content: '';

      position: absolute;
      top: 0;
      left: 0;

      width: var(--code-line-number-width);
      height: 100%;
      border-right: 1px solid var(--code-c-highlight-bg, var(--code-c-text));
      border-radius: var(--code-border-radius) 0 0 var(--code-border-radius);

      transition: border var(--vp-t-color);
    }

    pre {
      vertical-align: middle;
      margin-left: var(--code-line-number-width);
    }

    code {
      padding-left: 1rem;
    }

    .line-numbers {
      counter-reset: line-number;

      position: absolute;
      top: 0;
      left: 0;

      width: var(--code-line-number-width);
      padding-top: var(--code-padding-y);

      color: var(--code-c-line-number, var(--code-c-text));

      font-size: var(--code-font-size);
      line-height: var(--code-line-height);
      text-align: center;
    }

    .line-number {
      position: relative;
      z-index: 3;
      font-family: var(--code-font-family);
      user-select: none;

      &::before {
        content: counter(line-number);
        counter-increment: line-number;
      }
    }
  }
}
